#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;

const int N = 8003;
int n, t, a[N], pre[N];
int main()
{
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        set<int> num;
        for(int i = 1; i <= n; ++i)
        {
            scanf("%d", &a[i]);
            num.insert(a[i]);
            pre[i] = pre[i - 1] + a[i];
        }
        for(int i = 0; i < n - 1; ++i)
        {
            int j = i + 2;
            while(j <= n)
            {
                int sum = pre[j] - pre[i];
                num.erase(sum);
                set<int>::iterator it = num.upper_bound(sum);
                if(it == num.end())
                    break;
                else
                    j = lower_bound(pre + 1, pre + 1 + n, (*it) + pre[i]) - pre;
            }
        }
        int ans = 0;
        for(int i = 1; i <= n; ++i)
            if(num.find(a[i]) == num.end())
                ans++;
        printf("%d\n", ans);
    }
}
